const {ccclass, property, executionOrder} = cc._decorator;
import Actor from './actor/Actor'
import Player from './actor/Player'
var manager = require("XmdyManager")


import Poker from './Poker'
import NetStatus from './common/NetStatus';
@ccclass
@executionOrder(1)
export default class Game extends cc.Component {

    @property(NetStatus)
    netStatus:NetStatus = null;
    @property(cc.Label)
    roomId:cc.Label = null;
    
    @property(cc.Node)
    myPlayer:cc.Node= null;
    socket = null;
    //actors:Actor[] = [];
    onLoad() {
        
        this.socket = io('http://192.168.21.24:20021/room');
        this.netStatus.bindSocket(this.socket)
 
        
        this.schedule(this.netStatus.updateScan.bind(this.netStatus),1);
        this.socket.emit("add",{roomId:manager.room.roomId})
        
        this.socket.on("chatMessage",(msg)=>{
            debugger
            console.log("聊天内容:"+msg,typeof(msg))
        })

        this.roomId.string = manager.room.roomId;
        // cc.log("my0",this.myPlayer)
        // this.testProcess();
    }

    //测试流程
    testProcess(){

        let player:Player = this.myPlayer.getComponent(Player);
        player.cards([{type:0,name:1},{type:1,name:5},{type:2,name:5},{type:3,name:10},{type:4,name:14}]);
    }
   
    
    //准备


    //出牌
    chupai(){
              
      
    }   
    //翻拍
    fanpai(){
        debugger
    }
    //夕牌
    xipai(){
        cc.director.loadScene("Hall")
    }

    onDestroy(){
        
        if(this.socket){
            this.socket.disconnect();
        }
        
    }

}
